package you;

class MonitorTask implements Runnable{
	private boolean flag = false;
	private String word;
	public void stopMe(){
		this.flag=true;
	}
	public void sendWord(String word){
		this.word=word;
	}
	@Override
	public void run() {
		while(flag==false){
			if (this.word != null) {
				if (this.word.contains("alien")) {
					System.out.println(Thread.currentThread().getName() + " found alien in " + word);
				}
				this.word = null;
			}
			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
			}
		}
		System.out.println(Thread.currentThread().getName() + " stop");
		
	}
	
}

